package sz.szsmk.citizencard.ui.newversion.fragment.adapter

import android.content.Context
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import sz.szsmk.citizencard.ui.newversion.fragment.CardListCertificatesFragment
import sz.szsmk.citizencard.ui.newversion.fragment.CardListCouponFragment
import sz.szsmk.citizencard.ui.newversion.fragment.CardListTicketFragment

/**
 *  author : hyt
 *  date : 2020/8/18
 *  description :
 */
class CardListTabAdapter(private val context: Context, fm: FragmentManager)
    : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

    override fun getItem(position: Int): Fragment {
        return TAB_FRAGMENT[position]
    }

    override fun getPageTitle(position: Int): CharSequence? {
        return TAB_TITLES[position]
    }

    override fun getCount(): Int {
        return TAB_TITLES.size
    }
}

private val TAB_TITLES = arrayOf(
        "卡券",
        "票",
        "证件"
)

private val TAB_FRAGMENT = arrayOf(
        CardListCouponFragment.newInstance(),
        CardListTicketFragment.newInstance(),
        CardListCertificatesFragment.newInstance()
)